package com.briup.bookstore.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 支付宝配置类
 */
@Configuration
public class AlipayConfig {

    /**
     * 根据配置创建支付宝客户端
     *
     * @param alipayProperties 支付宝配置属性
     * @return 支付宝客户端
     */
    @Bean
    public AlipayClient alipayClient(AlipayProperties alipayProperties) {
        return new DefaultAlipayClient(
                alipayProperties.getGatewayUrl(),
                alipayProperties.getAppId(),
                alipayProperties.getSecretKey(),
                "json",
                alipayProperties.getCharset(),
                alipayProperties.getPublicKey(),
                "RSA2");
    }
}
